<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资产列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
    <div class="ui-layout-west">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa fa-sitemap"></i> 组织机构
                </div>
                <div class="box-tools pull-right">
                    <a type="button" class="btn btn-box-tool" href="javascript:void(0)" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
                    <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
                </div>
            </div>
            <div class="ui-layout-content">
                <div id="tree" class="ztree"></div>
                <div >
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>资产面积</h5>
                        </div>
                        <div class="ibox-content">
                            <div class="echarts"  style="width: 130px" id="echarts-pie-chart"></div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div class="ui-layout-center">
         <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <input type="hidden" id="deptId" value="204" name="deptId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>资产编号：</label>
                                    <input type="text" name="code"/>
                                </li>
                                <li>
                                    <label>资产名称：</label>
                                    <input type="text" id="name" name="name"/>
                                </li>
                                <li>
                                    <label>资产状态</label>
                                    <select name="state" id="state" th:with="type=${@dict.getType('land_state')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

<!--                <div class="btn-group-sm" id="toolbar" role="group">-->
<!--                    <a class="btn btn-success" onclick="add()" shiro:hasPermission="landhouse:assets:add">-->
<!--                        <i class="fa fa-plus"></i> 添加-->
<!--                    </a>-->
<!--                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="landhouse:assets:edit">-->
<!--                        <i class="fa fa-edit"></i> 修改-->
<!--                    </a>-->
<!--                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="landhouse:assets:remove">-->
<!--                        <i class="fa fa-remove"></i> 删除-->
<!--                    </a>-->
<!--                    <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="landhouse:assets:export">-->
<!--                        <i class="fa fa-download"></i> 导出-->
<!--                    </a>-->
<!--                </div>-->
                <div class="col-sm-12 select-table table-bordered">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
         </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <th:block th:include="include :: bootstrap-table-resizable-js" />
    <th:block th:include="include :: echarts-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('landhouse:assets:edit')}]];
        var removeFlag = [[${@permission.hasPermi('landhouse:assets:remove')}]];
        var landDatas = [[${@dict.getType('land_state')}]];
        var houseDatas = [[${@dict.getType('house_state')}]];
        var landTypes = [[${@dict.getType('land_type')}]];
        var houseTypes = [[${@dict.getType('house_type')}]];
        var landpurposeDatas = [[${@dict.getType('land_purpose')}]];
        var housepurposeDatas = [[${@dict.getType('house_purpose')}]];
        var key = [[${key}]];
        var prefix = ctx + "landhouse/assets";

        $(function() {
            var panehHidden = false;
            if ($(this).width() < 769) {
                panehHidden = true;
            }
            $('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
            // 回到顶部绑定
            if ($.fn.toTop !== undefined) {
                var opt = {
                    win:$('.ui-layout-center'),
                    doc:$('.ui-layout-center')
                };
                $('#scroll-up').toTop(opt);
            }
            queryDeptTree();
            queryUserList();
        });

        function queryUserList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "assets",
                columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         if (row.caseNo == null){
                //             actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="uploadSyncData1(\'' + row.id + '\')"><i class="fa fa-file"></i>附件</a> ');
                //         }else {
                //             actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="uploadSyncData2(\'' + row.id + '\')"><i class="fa fa-file"></i>附件</a> ');
                //         }
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="patrol(\'' + row.id + '\',\'' + row.address + '\')"><i class="fa fa-edit"></i>巡检记录</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     },
                //     width: 250
                // },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'type',
                    title: '资产类别',
                    formatter: function(value, row, index) {
                        if(row.caseNo == null) {
                            return $.table.selectDictLabel(houseTypes, value);
                        }else {
                            return $.table.selectDictLabel(landTypes, value);
                        }
                    },
                    width: 75
                },
                {
                    field: 'code',
                    title: '资产编号'
                },
                {
                    field: 'name',
                    title: '资产名称',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,5);
                    },
                    width: 100
                },
                {
                    field: 'address',
                    title: '资产地址',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,5);
                    },
                    width: 100
                },
                {
                    field: 'state',
                    title: '资产状态',
                    formatter: function(value, row, index) {
                        if(row.caseNo == null){
                            return $.table.selectDictLabel(houseDatas, value);
                        }else {
                            return $.table.selectDictLabel(landDatas, value);
                        }
                    }
                },
                {
                    field: 'orgLevel',
                    title: '企业层次',
                    visible: false
                },
                {
                    field: 'orgName',
                    title: '企业名称',
                    visible: false
                },
                {
                    field: 'caseNo',
                    title: '士地宗号',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,6);
                    }
                },
                {
                    field: 'acreage',
                    title: '土地面积',
                    visible: false
                },
                {
                    field: 'purpose',
                    title: '资产用途',
                    formatter: function(value, row, index) {
                        if(row.caseNo == null){
                            return $.table.selectDictLabel(housepurposeDatas, value);
                        }else {
                            return $.table.selectDictLabel(landpurposeDatas, value);
                        }
                    }
                },
                {
                    field: 'obtainTime',
                    title: '土地获得时间',
                    visible: false
                },
                {
                    field: 'obtainType',
                    title: '土地获取方式',
                    visible: false
                },
                {
                    field: 'transPrice',
                    title: '土地成交价'
                },
                {
                    field: 'transUnitPrice',
                    title: '土地成交单价',
                    visible: false
                },
                {
                    field: 'deedTax',
                    title: '契税',
                    visible: false
                },
                {
                    field: 'transServiceCharge',
                    title: '交易服务费',
                    visible: false
                },
                {
                    field: 'buyTotalPrice',
                    title: '购进价合计'
                },
                {
                    field: 'stampTax',
                    title: '印花税',
                    visible: false
                },
                {
                    field: 'overdueFine',
                    title: '士地滞纳金',
                    visible: false
                },
                {
                    field: 'factPurpose',
                    title: '实际用途',
                    visible: false
                },
                {
                    field: 'planChangeInfo',
                    title: '士地规划变更情况',
                    visible: false
                },
                {
                    field: 'plotRatio',
                    title: '土地容积率',
                    visible: false
                },
                {
                    field: 'property',
                    title: '土地性质',
                    visible: false
                },
                {
                    field: 'buildingProject',
                    title: '建设项目',
                    visible: false
                },
                {
                    field: 'buildingCompany',
                    title: '建设公司',
                    visible: false
                },
                {
                    field: 'longitude',
                    title: '经度',
                    visible: false
                },
                {
                    field: 'latitude',
                    title: '维度',
                    visible: false
                },
                {
                    field: 'landCode',
                    title: '地块编号',
                    visible: false
                },
                {
                    field: 'landCertificate',
                    title: '土地证号',
                    visible: false
                },
                {
                    field: 'deadline',
                    title: '使用期限',
                    visible: false
                },
                {
                    field: 'natureOfRight',
                    title: '权利性质',
                    visible: false
                },
                {
                    field: 'proportion',
                    title: '面积m2',
                    visible: false
                },
                {
                    field: 'recordDate',
                    title: '证书登记日期',
                    visible: false
                },
                {
                    field: 'place',
                    title: '土地资产证件位置',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,8);
                    },
                    visible: false
                },
                {
                    field: 'cardPlace',
                    title: '房产资产证件位置',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,8);
                    },
                    visible: false
                },
                {
                    field: 'manageCompany',
                    title: '委托代管公司',
                    visible: false
                },
                {
                    field: 'manageExpense',
                    title: '代管费用',
                    visible: false
                },
                {
                    field: 'manageStartDate',
                    title: '代管开始日期',
                    visible: false
                },
                {
                    field: 'manageEndDate',
                    title: '代管结束日期',
                    visible: false
                },
                {
                    field: 'manageAgreement',
                    title: '代管协议',
                    visible: false
                },
                {
                    field: 'progress',
                    title: '开发进度',
                    visible: false
                },
                {
                    field: 'planIndustrialAcreage',
                    title: '计划工业建筑面积(m2)',
                    visible: false
                },
                {
                    field: 'planBizAcreage',
                    title: '计划商业建筑面积(m2)',
                    visible: false
                },
                {
                    field: 'planResidenceAcreage',
                    title: '计划住宅建筑面积(m2)',
                    visible: false
                },
                {
                    field: 'planCarportAcreage',
                    title: '计划车库建筑面积(m2)',
                    visible: false
                },
                {
                    field: 'planAfforestAcreage',
                    title: '计划绿化面积(m2)',
                    visible: false
                },
                {
                    field: 'reorganize',
                    title: '整改情况',
                    visible: false
                },
                {
                    field: 'serviceLife',
                    title: '土地使用期限',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'createUserId',
                    title: '创建者ID',
                    visible: false
                },
                {
                    field: 'updateUserId',
                    title: '修改者ID',
                    visible: false
                },
                {
                    field: 'landAssetsId',
                    title: '土地资产ID',
                    visible: false
                },
                {
                    field: 'projectNo',
                    title: '项目编号',
                    visible: false
                },
                {
                    field: 'commercialPurpose',
                    title: '商业用途',
                    visible: false
                },
                {
                    field: 'position',
                    title: '区域位置',
                    visible: false
                },
                {
                    field: 'distribute',
                    title: '楼层分布',
                    visible: false
                },
                {
                    field: 'structure',
                    title: '房屋结构',
                    visible: false
                },
                {
                    field: 'buildingTime',
                    title: '修建年代',
                    visible: false
                },
                {
                    field: 'completedTime',
                    title: '竣工时间',
                    visible: false
                },
                {
                    field: 'adminCompany',
                    title: '管理单位',
                    visible: false
                },
                {
                    field: 'level',
                    title: '完好等级',
                    visible: false
                },
                {
                    field: 'overallDelivery',
                    title: '是否整体交付',
                    visible: false
                },
                {
                    field: 'noDeliveryCause',
                    title: '未交付原因',
                    visible: false
                },
                {
                    field: 'propertyRightCard',
                    title: '产权证号',
                    visible: false
                },
                {
                    field: 'cardRecordDate',
                    title: '证书登记日期',
                    visible: false
                },
                // {
                //     field: 'cardPlace',
                //     title: '证件位置'
                // },
                {
                    field: 'surveyCompany',
                    title: '测绘机构',
                    visible: false
                },
                {
                    field: 'surveyReport',
                    title: '测绘报告',
                    visible: false
                },
                {
                    field: 'parkingLotAmount',
                    title: '车位数量',
                    visible: false
                },
                {
                    field: 'parkingLotUsed',
                    title: '已出租车位数量',
                    visible: false
                },
                {
                    field: 'parkingLotRemanent',
                    title: '闲置车位数量',
                    visible: false
                },
                {
                    field: 'usedAcreage',
                    title: '已使用面积',
                    visible: false
                },
                {
                    field: 'floorHeight',
                    title: '层高',
                    visible: false
                },
                {
                    field: 'bearingCapacity',
                    title: '承重能力(kg/m^2)',
                    visible: false
                }
                ]
            };
            $.table.init(options);
        }

        function queryDeptTree() {
            var url = ctx + "system/common/deptTreeData/"+key;
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                var deptId = treeNode.id
                $("#deptId").val(deptId);
                $.ajax({
                    url: ctx+"system/common/getDictData/"+deptId,
                    type: 'post',
                    cache: false,
                    processData: false,
                    contentType: false,
                    dataType: "json",
                    success: function (result) {
                        var rows = result.rows;
                        var html=""
                        html +='<option value="">所有</option>';
                        $.each(rows,function (index,item) {
                            html +='<option value="'+item.dictValue+'">'+item.dictLabel+'</option>'
                        });
                        $("#state").html(html);
                    }
                });
                $.table.search();
            }
        }

        $('#btnExpand').click(function() {
            $._tree.expandAll(true);
            $(this).hide();
            $('#btnCollapse').show();
        });

        $('#btnCollapse').click(function() {
            $._tree.expandAll(false);
            $(this).hide();
            $('#btnExpand').show();
        });

        $('#btnRefresh').click(function() {
            queryDeptTree();
        });

        function dept() {
            var url = ctx + "system/assets";
            $.modal.openTab("资产管理", url);
        }

        function add(){
            var deptId = $("#deptId").val();
            $.modal.open("新增资产", prefix+"/addbyId/"+deptId);
        }

        function edit(id){
            var deptId = $("#deptId").val();
            $.modal.open("修改资产", prefix+"/edit/"+id+"/"+deptId);
        }

        function patrol(id,address){
            // var deptId = $("#deptId").val();
            $.modal.open("资产巡检记录", ctx+"system/property/patrol/"+id+"/"+address,'1400','800');
        }

        //房产附加
        function uploadSyncData1(id){
            $.modal.open("附件上传", ctx+"system/common/houseUpload/"+id);
        }
        //土地资产附件
        function uploadSyncData2(id){
            $.modal.open("附件上传", ctx+"system/common/landUpload/"+id);
        }

        var pieChart = echarts.init(document.getElementById("echarts-pie-chart"));
        var pieoption = {
            title : {
                // text: '资产面积',
                // subtext: '纯属虚构',
                x:'center'
            },
            //提示窗
            tooltip : {
                trigger: 'item',
                formatter: "{b} : ({d}%)",
                position: ['15%','50%']
            },
            //图裂
            legend: {
                orient : 'vertical',
                position : 'top',
                data:['自有资产','代管资产']
            },
            calculable : true,
            series : [
                {
                    name:'访问来源',
                    type:'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
                        {value:335, name:'自有资产'},
                        {value:50, name:'代管资产'}
                    ],
                    label: {
                        position: 'inside',
                        color: 'rgba(255, 255, 255, 0.3)'
                    },

                }
            ]
        };
        pieChart.setOption(pieoption);
        $(window).resize(pieChart.resize);
    </script>
</body>
</html>